package org.micro.test.entity.back.common;


import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableLogic;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.io.Serializable;
import java.sql.Timestamp;

/**
 * The Super Entity
 *
 * @author lry
 */
@Data
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class SuperEntity<T extends Model> extends Model<T> {

    private static final long serialVersionUID = 8345386306369511022L;

    /**
     * All entity table primary keys
     */
    @TableId(type = IdType.ID_WORKER)
    protected Long id;

    /**
     * The creator
     */
    protected Long creator;
    /**
     * The create time
     */
    @TableField(fill = FieldFill.INSERT)
    protected Timestamp createTime;

    /**
     * The changer
     */
    protected Long changer;
    /**
     * The chang time
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    protected Timestamp changTime;

    /**
     * The logically deleted markup
     * <p>
     * 注意：<p>
     * 1.会在mp自带查询和更新方法的sql后面，追加:『逻辑删除字段』=『LogicNotDeleteValue默认值』<p>
     * 2.删除方法: deleteById()和其他delete方法, 底层SQL调用的是: update tbl_xxx set 『逻辑删除字段』=『logicDeleteValue默认值』
     */
    @TableLogic
    @TableField(fill = FieldFill.INSERT)
    private Integer deleteFlag;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}